package com.ly.index.web.feign;

import com.ly.damai.entity.Product;
import com.ly.damai.entity.User;
import com.yc.bean.Result;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Component
// 一个服务只能定义一个接口
@FeignClient(name="cloud-other",fallback = OtherActionImpl.class)
public interface OtherAction {

    @RequestMapping("product/hots")
    List<Product> queryHots();

    @RequestMapping("/fegin/add")
        //服务端
    int add(@RequestParam("a") int a,
            @RequestParam("b") int b);

    @RequestMapping("/fegin/res")
    Result res(@SpringQueryMap Result result);

    @RequestMapping("/fegin/user")
    User user(@RequestBody User user,
              @RequestParam("myname") String myname);

    //请求方式的地址参数
    @RequestMapping("/fegin/hello/{na}")
    String hello(@PathVariable("nm") String name);

}
